package com.songlanyun.modules.material.controller.api;

import com.songlanyun.common.enums.MaterialConstant;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.material.service.SystemMaterialService;
import com.songlanyun.modules.user.controller.AbstractController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * 平台宣传素材
 *
 * @author zx
 * @date 2021年3月1日 11:42:07
 */
@RestController
@RequestMapping("api/material")
public class SystemMaterialApiController extends AbstractController {
    @Autowired
    private SystemMaterialService systemMaterialService;


    /**
     * 分页列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params) {
        params.put("state", MaterialConstant.StateEnum.RELEASE.getCode());
        PageUtils page = systemMaterialService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        return R.ok().put("data", systemMaterialService.getById(id));
    }

}
